package com.hunliji.monitor.web.controller.app;

import com.hunliji.common.response.PageData;
import com.hunliji.common.response.ResponseData;
import com.hunliji.monitor.service.api.model.param.QueryBusinessTableRecordParam;
import com.hunliji.monitor.web.facade.BusinessTableRecordFacade;
import com.hunliji.monitor.web.filter.auth.NeedAuth;
import com.hunliji.monitor.web.model.param.AddBusinessTableRecordParam;
import com.hunliji.monitor.web.model.param.EditBusinessTableRecordParam;
import com.hunliji.monitor.web.model.param.EditTableRecordParam;
import com.hunliji.monitor.web.model.vo.BusinessTableRecordVO;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * 表记录
 * @author wuchen
 */
@RestController
@RequestMapping("/appApi/businessTableRecord")
public class BusinessTableRecordController {
    @Resource
    private BusinessTableRecordFacade businessTableRecordFacade;

    /**
     * 添加记录
     * @param addBusinessTableRecordParam
     *
     */
    @PostMapping("/add")
    public ResponseData add(@RequestBody AddBusinessTableRecordParam addBusinessTableRecordParam){
        businessTableRecordFacade.add(addBusinessTableRecordParam);
        return ResponseData.success(null);
    }

    /**
     * 修改记录
     * @param editTableRecordParam
     */
    @PostMapping("/update")
    public ResponseData update(@RequestBody EditTableRecordParam editTableRecordParam){
        businessTableRecordFacade.update(editTableRecordParam);
        return ResponseData.success(null);
    }

    /**
     * 删除记录
     * @param id
     */
    @PostMapping("/delete")
    public ResponseData delete(@RequestParam("id") Long id){
        businessTableRecordFacade.delete(id);
        return ResponseData.success(null);
    }

    /**
     * 分页查询
     * @param queryBusinessTableRecordParam
     * @return
     */
    @NeedAuth
    @PostMapping("/queryPage")
    public ResponseData<PageData<BusinessTableRecordVO>> queryPage(@RequestBody QueryBusinessTableRecordParam queryBusinessTableRecordParam){
        return ResponseData.success(businessTableRecordFacade.queryPage(queryBusinessTableRecordParam));
    }
}
